package game;

import java.awt.Color;
import java.awt.event.MouseEvent;

public class GameoverMenu extends Menu{
    private int currentTrans;
    private Menu tempMenu;

    public GameoverMenu(GrandeCanvas c) {
        super(c);
        init();
        
    }

    public void init(){
        elements.add(new MenuButton(this, 500, 375, 200, 50, "Restart", 30, null){
            @Override
            public void clicked(MouseEvent e){
                canvas.level.mario.x = canvas.level.spawn.x;
                canvas.level.mario.y = canvas.level.spawn.y;
                canvas.resumeGame();
                canvas.menu = tempMenu;
            }
        });
        elements.add(new MenuButton(this, 750, 375, 200, 50, "Quit", 30, null){
            @Override
            public void clicked(MouseEvent e){
                canvas.quitGame();
            }
        });
        canvas.drawing = false;
        canvas.paused = true;
        tempMenu = canvas.menu;
        canvas.menu = this;
    }
    
    @Override
    public void draw(){
        if(canvas.bufGraphics != null){
            if(currentTrans < 254) currentTrans += 2;
            canvas.bufGraphics.setColor(new Color(160, 0, 0, currentTrans));
            canvas.bufGraphics.fillRect(0, 0, canvas.fwidth, canvas.fheight);
            super.draw();
        }
    }

    @Override
	public void mousePress(MouseEvent event){
        for(MenuItem item: elements){
            if(item.contains(event.getX(), event.getY())){
                item.clicked(event);
            }
        }
    }
}
